package com.delu.service.impl;

import com.delu.data.Result;
import com.delu.em.ResultEnum;
import com.delu.entity.IntegralExperience;
import com.delu.entity.Wallet;
import com.delu.mapper.IntegralExperienceMapper;
import com.delu.mapper.WalletMapper;
import com.delu.service.IWalletService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2021-12-18
 */
@Service
public class WalletServiceImpl extends ServiceImpl<WalletMapper, Wallet> implements IWalletService {
    @Autowired
    private WalletMapper walletMapper;
    @Autowired
    private IntegralExperienceMapper integralExperienceMapper;
    @Override
    public Result SelectWalletByUserId(Long userId, int type) {
            Wallet wallet = walletMapper.SelectWalletByUserId(userId);
            if (type == 1){
                return Result.response(ResultEnum.SUCCESS).setData(wallet.getBalanceAccount());
            }
            if (type == 2){
                return Result.response(ResultEnum.SUCCESS).setData(wallet.getDebt());
            }
            if (type == 3){
                //通过钱包表中的userid查询所属储蓄卡
                Wallet wlist =  walletMapper.selectStorageCrad(userId);
                return Result.response(ResultEnum.SUCCESS).setData(wlist);
            }
            if (type == 4){
                IntegralExperience integralExperience = integralExperienceMapper.selectExperince(userId);
                return Result.response(ResultEnum.SUCCESS).setData(integralExperience);
            }
        return null;
    }
}
